import { Injectable } from '@angular/core';
import { NzModalService } from 'ng-zorro-antd';

@Injectable({
  providedIn: 'root'
})
export class CommonService {

  constructor(private modalService: NzModalService) { }
  /**公用alert */
  alert(msg) {
    this.modalService.warning({
      nzTitle: '提示信息',
      nzContent: `${msg}`
    });
  }

  /**公用confirm */
  confirm(title: any, okfun: Function, canfun?: Function) {
    this.modalService.confirm({
      nzTitle: title,
      nzContent: '',
      nzOkText: '是',
      nzOkType: 'danger',
      nzOnOk: () => {
        okfun();
      },
      nzCancelText: '否',
      nzOnCancel: () => {
        if(canfun){
          canfun();
        }
      }
    });
  }

}

